package chapter10.innerclass.HomeWork;

/**
 * @Auther: Tx
 * @Date: 2022/5/3 13:38
 */
public class Person {
    private String name;
    private Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }
// 把具体的要求封装成方法
    public void passRiver(){
      if (!(vehicles instanceof Boat)){
          vehicles = VehiclesFactory.getBoat();
      }
      vehicles.work();
    }
    public  void commonPass(){
        if (!(vehicles instanceof Horse)){
            vehicles = VehiclesFactory.getHorse();
        }
        vehicles.work();
    }
 public void passFire(){
     if (!(vehicles instanceof Airplane)){
         vehicles = VehiclesFactory.getAirplane();
     }
     vehicles.work();
 }
}
